refactor(server): effectify session summary route handlers#1024
Conversation
|
Warning Review limit reached
More reviews will be available in 35 minutes and 12 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors the 'diff' and 'artifacts' session route handlers in 'session.ts' to run within the 'AppRuntime' using Effect generators and resolve 'SessionSummary.Service' dynamically. Additionally, it updates the integration tests in 'session-runtime-routes.test.ts' to include assertions for the '/session/:sessionID/diff' endpoint. No review comments were provided, so there is no additional feedback to address.
Part of the #936 Effect-route migration. Moves the session message route handlers off direct Session.* async calls onto AppRuntime.runPromise + Effect.gen service access via Session.Service. Change boundary: - packages/opencode/src/server/instance/session.ts only: the GET messages handler (all three existing branches: limit undefined -> full list, limit 0 -> full list, limit > 0 -> messagesPage with the next-page Link header), the DELETE message part handler (removePart), and the PATCH message part handler (updatePart, with its body/param mismatch guard preserved before the runtime call). The undefined/0/positive branch structure and the pagination Link/cursor headers are kept 1:1 with dev; only the call sites are routed through the app runtime. - test/server/session-messages.test.ts: adds a messages() helper and a new test exercising PATCH part (text before -> after) and DELETE part (returns true, resulting parts length 0). Verification: - Rebased onto latest origin/dev (clean, no conflict with #1024). - test/server/session-messages.test.ts: 10 tests / 43 expects pass. - tsgo typecheck clean. - Independent `codex review --base origin/dev`: no actionable behavior-breaking issues; focused test + typecheck + git diff --check verified. - Full PR CI green. Review follow-up: - Gemini medium (collapse the identical limit===undefined / limit===0 branches): kept the branch structure as-is. It is the pre-existing dev control flow and is correct (Session.messages treats a falsy limit as "return the full unpaginated list", so limit===0 is handled, not blocked); deduplicating it is an adjacent cleanup outside this behavior-preserving migration's scope. Resolved with rationale. Residual risk: none beyond the migration itself; external route surface unchanged and covered by tests. Refs #936
Part of the #936 Effect-route migration. Moves the session core route handlers off direct Session.* async calls onto AppRuntime.runPromise + Effect.gen service access via Session.Service. Change boundary: - packages/opencode/src/server/instance/session.ts only: GET /session/:sessionID (get), GET /session/:sessionID/children, DELETE /session/:sessionID (remove), PATCH /session/:sessionID (update), and POST /session/:sessionID/fork. The PATCH update handler folds its get -> conditional setTitle/setPermission/ setArchived -> re-get sequence into one Effect.gen, preserving the original order and the Permission.merge(current.permission ?? [], updates.permission) logic 1:1. - Does NOT touch the prompt/respond, tool, turn-change, or force-delete handlers or their semantics; only the five core CRUD handlers above are routed through the app runtime. - Adds test/server/session-core-routes.test.ts covering get/children/update/ fork/delete, following the same run()/svc wrapper convention as the sibling session route test files. Verification: - Rebased onto latest origin/dev (clean, no conflict with #1023/#1024). - Session route tests (core + messages + runtime-routes): 12 tests / 68 expects pass; no regression in the shared session.ts surface. - tsgo typecheck clean. - Independent `codex review --base origin/dev`: no regressions requiring a fix; focused + adjacent server/session/workspace tests + typecheck verified. - Full PR CI green. Review follow-up: - Gemini medium (test-only: replace run()/svc wrapper with `const svc = SessionNs`): kept the wrapper, which is the established convention shared verbatim by the sibling session route tests already on dev; test-only, no production impact, suite passes. Resolved with rationale. Residual risk: none beyond the migration itself; external route surface unchanged and covered by tests. Refs #936
Summary
Effectify the session diff and artifacts JSON handlers.
Why
Issue #936 is moving route handlers onto AppRuntime-backed services while preserving the existing HTTP API shape. This keeps the read-only session summary routes on
SessionSummary.Servicewithout touching summarize, prompt, share, revert, or permission behavior.Related Issue
Fixes part of #936.
Human Review Status
Pending
Review Focus
Please focus on whether
/:sessionID/diffand/:sessionID/artifactspreserve their existing response shape and remain limited to read-only summary routes.Risk Notes
No visible UI or copy changed, so the UI checklist item is not applicable.
No platform, packaging, updater, signing, path, shell, or permissions surface was touched, so the platform checklist item is not applicable.
No docs, release notes, dependencies, permissions, credentials, deletion behavior, generated content, or local file surface changed beyond the focused route test update.
How To Verify
Screenshots or Recordings
Not applicable: no visible UI changes.
Checklist
bug,enhancement,task,documentation. Type labels are author-added; the labeler bot does NOT assign them. Add the label in the GitHub UI, then tick this.app,ui,platform,harness,ci. The labeler bot assigns these on PR open based on changed paths. Confirm the bot's choice (or override if wrong), then tick this.P0,P1,P2,P3. The priority-triage bot suggests one on PR open. Confirm or override, then tick this.Pending,Approved by @<reviewer>, orNot required: <reason>(default isPending; "not required" is restricted to bot-authored low-risk PRs).dev, and my PR title and commit messages use Conventional Commits in English.